package store.swing;

import javax.swing.*;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import java.awt.*;

public abstract class DefaultTable extends JTable {
    private static final Font DEFAULT_HEADER_FONT = new Font("Tahoma", Font.BOLD, 20);
    private static final Font DEFAULT_TABLE_FONT = new Font("Tahoma", Font.PLAIN, 16);
    private static final int DEFAULT_ROW_HEIGHT = 25;

    private TableRowSorter<TableModel> sorter;


    public DefaultTable(TableModel tableModel) {
        setModel(tableModel);
        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        sorter = new TableRowSorter<>(tableModel);
        setRowSorter(sorter);
        getTableHeader().setFont(DEFAULT_HEADER_FONT);
        setFont(DEFAULT_TABLE_FONT);
        setRowHeight(DEFAULT_ROW_HEIGHT);
    }

    public TableRowSorter<TableModel> getSorter() {
        return sorter;
    }
}
